@extends('admin._layouts.default')

@section('main')


      <div class="row-fluid ">
        <div class="span12 box gradient ">
      <div class="title">
            <div class="row-fluid">
                <h3><a href="#"  class="btn btn-danger btn-mini pull-right mg5"><i class="fa fa-thumbs-down"></i> 只看差评</a> <a href="#"  class="btn btn-warning btn-mini pull-right mg5"><i class="fa fa-history"></i> 只看未派单</a>
                 <i class="fa  fa-truck"></i> 工单管理
                </h3>
            </div>
        </div><!-- End .title -->
        <div class="content min_h500">
            <table id="datatable_in" class="responsive table table-striped" style="width:100%;margin-bottom:0; ">
              <thead>
               <tr>
                 <th width="120">
                   客户
                  </th>
                   <th width="">
                       客户所属直营商
                   </th>
                  <th>
                    联系方式
                  </th>
                  <th>
                    申请时间
                  </th>
                  <th width="120">
                    服务类型
                  </th>
                  <th width="120">
                    服务时间
                  </th>
                  <th width="120">
                    状态
                  </th>
                  <th width="150">
                   客户评价
                  </th>
                 <th width="100">
                   操作
                 </th>
               </tr>
              </thead>
              <tbody>
              @foreach($services as $service)
               <tr>
                  <td>
                    <i class="fa fa-user"></i> {{ $service->mount->mount_name }} @if($service->mount->sex == 1)先生 @else 女士 @endif
                  </td>
                   <td>
                       {{ $service->customer->areaname->name }}
                   </td>
                 <td>
                    <i class="fa fa-mobile"></i> {{ $service->mount->mount_mobile }} <i class="fa fa-home"></i>{{ $service->mount->area->name }} {{ $service->mount->address }}
                  </td>
                  <td>
                  {{ $service->created_at }}
                  </td>
                  <td>
                  @if($service->type == 1)
                    试用申请
                  @elseif($service->type == 10)
                    {{--订购（付款方式：@if($service->paytype == 1)付现金--}}
                                         {{--@elseif($service->paytype == 2)--}}
                                          {{--微信支付--}}
                                              {{--@if($service->all == 1)--}}
                                              {{---已完成--}}
                                              {{--@else--}}
                                                {{---未完成--}}
                                              {{--@endif--}}
                                          {{--@endif--}}
                                          {{--）--}}

                                          签约申请
                  @elseif($service->type == 11)
                    {{--拆机--}}
                    售后申请
                  @elseif($service->type == 12)
                    {{--维修--}}
                    服务申请
                  @elseif($service->type == 13)
                    {{--换芯<span class="badge">{{ $service->commodity->name }}</span>--}}
                    服务申请
                  @endif
                 </td>
                 <td>
                    {{ $service->remark }}
                 </td>
                 <td>
                  @if($service->state== 1)
                    尚未派单
                  @elseif($service->state == 2)
                    {{ $service->work->name }}负责上门
                  @elseif($service->state == 3)
                    {{ $service->work->name }}已完成
                  @endif
                 </td>
                 <td>
                  @if($service->rate_id== 0)
                    尚未评价
                  @else
                    @if($service->rate->form1 >3)
                    好评
                    @elseif($service->rate->form1 < 1)
                    差评
                    @else
                    中评
                    @endif
                  @endif
                 </td>
                 <td>
                    <div class="btn-group1">
                      @if($service->state== 1)
                      <a class="btn btn-small" onclick="set_id('{{ $service->id }}');" rel="tooltip" data-placement="left" data-original-title="派单" data-toggle="modal" data-target="#work_out"><i class="fa fa-bicycle"></i></a>
                     @endif
                     <a class="btn btn-inverse btn-small" rel="tooltip" data-placement="bottom" data-original-title="删除工单" data-toggle="modal" data-target="#confirm_alert"><i class="gicon-remove icon-white"></i></a>
                   </div>
                 </td>
               </tr>
               @endforeach
               </tbody>
            </table>
                <div class="row-fluid control-group">

                    <div class="pagination pull-right ">
                      <?php echo $services->links(); ?>
                  </div>
                </div>
                <br/>


            </div>
        </div>
        <!-- End box -->
      </div>


@stop


@section('modals')
<div id="work_out" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 class="modal-title" id="myModalLabel">员工列表</h3>
      </div>
      <div class="modal-body">
          {{--<div class="form-row control-group row-fluid">--}}
            {{--<div class="controls span9">--}}
              {{--<div class="input-append row-fluid">--}}
                {{--<input type="text" class="span5" id="search-input" placeholder="搜索员工">--}}
                {{--<button type="submit" class="btn">搜索</button>--}}
              {{--</div>--}}
            {{--</div>--}}
          {{--</div>--}}

            {{ Form::open(array('route' => 'admin.services.paidan','id'=>'works','class'=>'form-horizontal')) }}
          <input type="hidden" name="service_id" value="" id="service_id">
          <table class="table">
            <thead>
            <tr>
              <th width="60">
                选择
              </th>
              <th width="80">
                头像
              </th>
              <th>
                姓名
              </th>
              @if($user->hasAccess('city'))
              <th>
                分销商
              </th>
              @endif
            </tr>
            </thead>
            <tbody>
            @foreach($works as $work)
            <tr>
              <td>
                <input type="radio" name="radio" value="{{ $work->id }}" />
              </td>
              <td>
               <img class="thumbnail small" src="{{ $work->avatar }}">
              </td>
              <td>
                {{ $work->name }}
              </td>
              @if($user->hasAccess('city'))
              <th>
                {{ $work->section->name }}
              </th>
              @endif
            </tr>
            @endforeach

            </tbody>
          </table>
        {{ Form::close() }}

      </div>
      <div class="modal-footer">
                <div class="row-fluid control-group">
                  <div class="pull-left span6" action="#">
                    <div class="pagination pull-left ">
                    </div>
                  </div>
                  <div class="span6">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" onclick="sub_paidan();" class="btn btn-primary">确定</button>
                  </div>
                </div>


      </div>
    </div>
  </div>
</div>

<div id="confirm_alert" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 class="modal-title" id="myModalLabel">确定本次操作吗？</h3>
      </div>
      <div class="modal-body">
        <i class=" icon-warning-sign color_red pull-left fs_24"></i>

        <p>一旦【确定】，本次操作不可撤销。</p>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" id="" class="btn btn-primary">确定</button>
      </div>
    </div>
  </div>
</div>
@stop


@section('script')
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/full-calendar/fullcalendar.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/jquery.peity.min.js') }}"></script>
<script type="text/javascript" language="javascript" src="{{ URL::asset('ad/js/plugins/datatables/js/jquery.dataTables.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/chosen/chosen/chosen.jquery.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/flot/jquery.flot.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/jquery.uniform.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/plugins/justGage.1.0.1/resources/js/raphael.2.1.0.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/plugins/justGage.1.0.1/resources/js/justgage.1.0.1.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/scripts.js') }}"></script>


    <script type="text/javascript" charset="utf-8">
    // Datatables
    $(document).ready(function() {
      var dontSort = [];
                $('#datatable_city thead th').each( function () {
                    if ( $(this).hasClass( 'no_sort' )) {
                        dontSort.push( { "bSortable": false } );
                    } else {
                        dontSort.push( null );
                    }
      } );
      $('#datatable_city').dataTable( {
        "sDom": "<'row table_top_bar'<'row-fluid'>'<'to_hide_phone'>'f'<'>r>t<'row'>",
         "sDom": "<'row table_top_bar'<'row-fluid'<'to_hide_phone' f>>><'row'>",
         "aaSorting": [[ 1, "asc" ]],
        "bPaginate": false,
        "bJQueryUI": false,
        "aoColumns": dontSort

      } );
      $.extend( $.fn.dataTableExt.oStdClasses, {
        "s`": "dataTables_wrapper form-inline"
      } );
    } );
    </script>
    <script>
    function set_id(id){
        $('#service_id').val(id);
    }
    function sub_paidan(){
        $('#works').submit();
    }
    </script>
@stop
